package com.dynamic.mybatis.core.toolkit;

import com.baomidou.mybatisplus.core.toolkit.ClassUtils;
import net.sf.cglib.beans.BeanMap;

import java.util.Map;

/**
 * @Description
 * @Author xs
 * @Date 2021/11/10 18:01
 */
public class BeanUtil {

    public static <T> T copy(T bean) {
        Map map = null == bean ? null : BeanMap.create(bean);
        T copyBean = ClassUtils.newInstance((Class<T>) bean.getClass());
        BeanMap.create(copyBean).putAll(map);
        return copyBean;
    }


}